function A0_coef = MMP_limiter(A0_coef,k,N,b_fun,basis)
New_A0_coef = zeros(size(A0_coef));
max_value = 1;
min_value = -1;
uh_aver = get_average(A0_coef,basis,N);
basis_value = zeros(k+1,2);
for l = 1 : k+1
    basis_value(l,1) = b_fun{l}(-1);
    basis_value(l,2) = b_fun{l}(1);
end
if k == 1
    M = zeros(k+1,k+1);
    for l = 1 : k+1
        M(1,l) = b_fun{l}(-1);
        M(2,l) = b_fun{l}(1);
    end
else
    M = zeros(k+1,k+1);
    for l = 1: k+1
        M(1,l) = b_fun{l}(-1);
        M(2,l) = b_fun{l}(1);
        M(3,l) = (1/2)*quadgk(b_fun{l},-1,1);
    end
end
for i = 1 : N
    %求每个区间上的最大值和最小值
    % x_min = fminbnd(uh{i},-1,1);
    % x_max = fminbnd(@(x)(-1)*uh{i}(x),-1,1);
    % max_inter = uh{i}(x_max);
    % min_inter = uh{i}(x_min);
    [max_inter,min_inter] = get_extrema(A0_coef(:,i),b_fun,k);
    a = (max_value-uh_aver(i))/(max_inter-uh_aver(i));
    b = (uh_aver(i)-min_value)/(uh_aver(i)-min_inter);
    theta = min(1,min(a,b));
    % uh{i} = @(x) theta*uh{i}(x) + (1-theta)*uh_aver(i);
    %算新系数
    u_ori_right = A0_coef(:,i)'*basis_value(:,2);
    u_ori_left = A0_coef(:,i)'*basis_value(:,1);
    u_right = theta*u_ori_right + (1-theta)*uh_aver(i);
    u_left = theta*u_ori_left + (1-theta)*uh_aver(i);
    % u_right = uh{i}(1);
    % u_left = uh{i}(-1);
    if k == 1
        b = [u_left;u_right];
        New_A0_coef(:,i) = M\b;
    elseif k==2
        b = [u_left;u_right;uh_aver(i)];
        New_A0_coef(:,i) = M\b;
    end
end
A0_coef = New_A0_coef;
end